<template>
  <div>
    <el-select :value="catalogID" placeholder="请选择" style="width: 400px;" @change="onChange">
      <!-- <el-option label="区域一" value="shanghai"></el-option> -->
      <el-option v-for="item in directorysList" :key="item.id" :label="item.directoryName" :value="item.id"></el-option>
    </el-select>
  </div>
</template>

<script>
// 导入目录列表接口
import { list } from '../../api/hmmm/directorys'
export default {
  props: ['subjectID', 'catalogID'],
  data () {
    return {
      directorysList: []
    }
  },
  watch: {
    subjectID (oldVal, newVal) {
      if (oldVal) {
        this.getDirectorysList()
      }
    }
  },
  methods: {
    // 获取目录列表接口
    async  getDirectorysList () {
      const data = await list({
        subjectID: this.subjectID,
        page: 1,
        pagesize: 10

      })
      this.directorysList = data.data.items
    },
    // 选中时触发
    onChange (id) {
      this.$emit('update:catalogID', id)
    }
  }
}
</script>

<style>

</style>
